#include "fs/fs.h"
#include "fs/inode.h"
#include "fs/dentry.h"

static uint devfs_dhash(dentry_t* dentry, qstr_t* name)
{
	uchar *start;
	uchar *end;
	uint hash = init_name_hash();

	kassert(NULL != dentry && NULL != name);
	start = name->str;
	end = start + name->size;
	for (; start != end; ++start)
		hash = partial_name_hash(*start, hash);
	return end_name_hash(hash);
}

static int devfs_dcompare(dentry_t* dentry, qstr_t* name)
{
	return strncmp((const char*)dentry->name,
		(const char*)name->str, name->size);
}

// static data
static dentry_operations_t devfs_dops =
{
	devfs_dhash,
	devfs_dcompare,
};

static inode_operations_t devfs_iops;

void global_init_devfs_module(void)
{
	if (_fs_create(&devfs, "devfs", &devfs_dops, &devfs_iops))
		bug("global_init_devfs_module: fail to create devfs.\n");
}
